Agents Manager: open the floating chat on the right at default size on responsive undock - #113361
Agents Manager: open the floating chat on the right at default size on responsive undock#113361wellyshen wants to merge 5 commits into
Conversation
|
WordPress.com
Automattic for Agencies
|
67cec9c to
f1267d8
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds responsive-undock awareness to the agent layout flow and centralizes floating panel positioning/size props so the chat can re-seed to the right corner when undocked due to viewport changes.
Changes:
- Introduces a
ResponsiveUndockContextand passes a responsive-undock flag through the agent portal. - Adds
useFloatingPanelPropsto standardize mount-time seeding + persistence wiring forAgentUI.Container. - Updates components/tests to remount the container on dock/undock and validate responsive-undock behavior and persistence.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/agents-manager/src/hooks/use-floating-panel-props/index.ts | New hook for AgentUI.Container floating position/size props, with responsive-undock seeding. |
| packages/agents-manager/src/hooks/use-agent-layout-manager/responsive-undock-context.ts | New context + hook to expose “responsive undock” status to portal children. |
| packages/agents-manager/src/hooks/use-agent-layout-manager/index.tsx | Provides responsive-undock flag to portal children; extends onUndock callback with a boolean. |
| packages/agents-manager/src/hooks/use-agent-layout-manager/README.md | Documents the new onUndock(isResponsiveUndock) contract and the context usage. |
| packages/agents-manager/src/hooks/tests/use-floating-panel-props.test.tsx | Adds unit tests for the new floating panel props hook, including responsive-undock seeding. |
| packages/agents-manager/src/hooks/tests/use-agent-layout-manager.test.tsx | Adds tests verifying responsive-undock flag propagation and onUndock(true/false) semantics. |
| packages/agents-manager/src/constants.ts | Adds a seed constant intended to force right-corner placement via clamping. |
| packages/agents-manager/src/components/support-guides/index.tsx | Refactors to use useFloatingPanelProps and remounts container on dock/undock. |
| packages/agents-manager/src/components/support-guide/index.tsx | Refactors to use useFloatingPanelProps and remounts container on dock/undock. |
| packages/agents-manager/src/components/agent-history/index.tsx | Refactors to use useFloatingPanelProps and remounts container on dock/undock. |
| packages/agents-manager/src/components/agent-dock/index.tsx | On responsive undock, persists “right + default size” floating state (store + localStorage). |
| packages/agents-manager/src/components/agent-chat/index.tsx | Refactors to use useFloatingPanelProps and remounts container on dock/undock. |
| packages/agents-manager/src/components/tests/agent-dock.test.tsx | Adds coverage for responsive-undock persistence behavior in AgentDock. |
| packages/agents-manager/src/components/tests/agent-chat.test.tsx | Adds coverage to ensure container remount happens only when dock state changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
packages/agents-manager/src/hooks/use-agent-layout-manager/index.tsx:73
- The API uses both
isResponsiveUndock(callback param/docs) anduseIsResponsiveUndocked/isResponsiveUndocked(context + internal variable). Standardizing on one name (e.g.isResponsiveUndockedeverywhere) would reduce confusion for consumers and keep terminology consistent across the hook, context, and README.
/** `isResponsiveUndock` is true when the undock was forced by the viewport narrowing below `desktopMediaQuery`. */
onUndock?: ( isResponsiveUndock: boolean ) => void;
packages/agents-manager/src/components/agent-dock/index.tsx:167
- On responsive undock,
setFreeDragPosition( null )andsetFloatingSize( null )are dispatched unconditionally. If the persisted values are alreadynull, this can trigger unnecessary store updates and rerenders. Consider selecting the currentfreeDragPosition/floatingSizehere and only dispatching when a change is actually needed (similar to the existing guard forfloatingPosition).
if ( floatingPosition !== 'right' ) {
setFloatingPosition( 'right' );
}
setFreeDragPosition( null );
setFloatingSize( null );
packages/agents-manager/src/components/tests/agent-dock.test.tsx:475
- This test hardcodes the storage key string even though the production code now defines
AGENTTIC_CHAT_POSITION_STORAGE_KEY. Import and use the constant in the test to keep it aligned with future key changes and avoid duplicated literals.
expect( localStorage.getItem( 'agenttic-chat-position' ) ).toBe( 'right' );
johngodley
left a comment
There was a problem hiding this comment.
This generally works as described. I've left a couple of comments for specific code. I'll approve based on these are probably small changes, but I can take another look too.
Also, I'm not sure if this is intended behaviour or a problem:
- Start with agent in sidebar
- Reduce width to docked
- Move agent to top left
- Expand width to move back to sidebar
- Reduce width to docked. It's now on the bottom right again
| const canDock = useCanDock( { desktopMediaQuery } ); | ||
| const { canDock, isDesktop } = useCanDock( { desktopMediaQuery } ); | ||
| const shouldRenderSidebar = canDock && isDocked; | ||
| const isResponsiveUndocked = !! isDocked && ! isDesktop; |
There was a problem hiding this comment.
I think this is causing a problem when the component is remounted.
- Start with agent in sidebar
- Reduce width to make it docked
- Move to left, and resize to a large width and height
- Press the 'View History' button (so changing route)
- Agent is now docked to the right and small
| defaultSize={ floatingSize ?? undefined } | ||
| onResizeEnd={ setFloatingSize } | ||
| // Remount on dock/undock so the mount-only seed props re-apply. | ||
| key={ isDocked ? 'embedded' : 'floating' } |
There was a problem hiding this comment.
My agent says there could be a problem with this key in Zendesk as it's based on undefined data. I don't know if this is still used or how to confirm it.
A user is chatting with a Happiness Engineer through Zendesk in the docked sidebar and has typed a half-finished message. They drag the browser window narrower past the desktop breakpoint (or click "Move to sidebar" / the dock toggle). shouldRenderSidebar flips, the key goes 'embedded' → 'floating', React unmounts and remounts the container, and the internal input state reinitializes to ''. The typed message is gone with no way to recover it.
…nsive undock When the docked sidebar is forced into floating mode by the viewport narrowing below the desktop media query, the chat now opens at the right corner (where the sidebar was) at the default size, and persists that as the new floating state. Manual pop-outs and fullscreen-gate undocks keep restoring the user's persisted position and size. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
abe28a7 to
eed0274
Compare
|
Looks like one of the E2E tests has failed. You can fix them following these steps:
|
The right-corner seed now applies only until the user repositions the responsive-undocked chat — a drag or resize survives route changes and close/reopen instead of being reset on every remount. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The layout manager now counts responsive undocks and the floating panels key on that count, so the remount that re-applies the right-corner seed happens on every switch — not only the first — while drags/resizes made in between are still kept. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@johngodley Thanks for the review. These regressions are real — the new Closing this PR — the proper fix is on the |
Fixes AI-1099
Proposed Changes
useAgentLayoutManager:onUndocknow receivesisResponsiveUndock: boolean, and portal children can read the same signal at render time via a newResponsiveUndockContext(useResponsiveUndock()— the flag plus a per-undock counter); the hook README is updated.useFloatingPanelPropshook consolidates the previously duplicated floating-panel store wiring acrossagent-chat,agent-history,support-guide, andsupport-guides, and applies the responsive-undock seed overrides in one place.AgentUI.Containers get akey(fromuseFloatingPanelProps) covering the dock state and the responsive-undock counter, so the panel remounts — and re-reads its mount-only position/size seeds — on dock/undock and on every responsive undock. Without it, the panel keeps the position it seeded at page load (the portal children reconcile in place across the dock switch).AgentDockpersists the new floating state in theonUndockhandler:floatingPosition: 'right'(guarded to avoid redundant saves), cleared sessionfreeDragPosition/floatingSize, andagenttic-ui's ownagenttic-chat-positionlocalStorage key (it takes precedence over theinitialChatPositionprop at seed time).Why are these changes being made?
Testing Instructions
Calypso
yarn start-dashboard2026-08-07.4.13.48.mov
2026-08-07.4.17.39.mov
Simple/Atomic (sandbox)
cd apps/agents-manager && yarn dev --syncwidgets.wp.com(onlywidgets.wp.comneeds sandboxing, not the site itself) and open any site's wp-adminPre-merge Checklist
🤖 Generated with Claude Code